package com.wxapp.sale.service.controller.client;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.common.constant.pojo.vo.UserVo;
import com.wxapp.common.core.annotation.User;
import com.wxapp.common.core.filter.except.ThrowMyException;
import com.wxapp.sale.api.pojo.vm.order.POrderPageVm;
import com.wxapp.sale.api.pojo.vo.order.QOrderAddVo;
import com.wxapp.sale.api.pojo.vo.order.QOrderPageVo;
import com.wxapp.sale.service.service.OrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lgl
 * @Description 订单管理
 * @Datetime 2022/7/5 9:01
 * @Modified By
 */
@RestController
@Tag(name = "订单管理")
@RequestMapping("/client/order")
@RequiredArgsConstructor
public class OrderClientController extends IBaseController {
    private final OrderService orderService;

    @PostMapping("add")
    @Operation(summary = "添加订单")
    public ResultVm<String> add(@Schema(hidden = true) @User UserVo user, @RequestBody QOrderAddVo vo){
        return orderService.add(vo, user);
    }

    @DeleteMapping("delete")
    @Operation(summary = "删除订单")
    public ResultVm<String> delete(@RequestBody List<String> codes) throws ThrowMyException {
        return orderService.delete(codes);
    }
    @PostMapping("page")
    @Operation(summary = "订单列表")
    public ResultVm<IPage<POrderPageVm>> page(@RequestBody QOrderPageVo vo, @Schema(hidden = true) @User UserVo user){
        return orderService.page(user,vo);
    }
}

